<?php
include_once 'titulo.php';
if ($_SESSION['IdUsuario']) {
    ?>

    <html>
        <head>
            <title> editar instalação</title>
            <?php
            include_once 'MySQL.php';
            include_once 'cabecalho.php';
            include_once 'script/functions.php';
            ?>

            <title>Vidracaria</title>
            <script src="script/jquery.maskMoney.js" type="text/javascript"></script>
            <script type="text/javascript" src="script/jquery.maskedinput-1.3.min.js"></script>
            <script>
                $(function(){
                    $("#real").maskMoney({symbol:"R$",decimal:".",thousands:""});
                    $("#entrada").maskMoney({symbol:"R$",decimal:".",thousands:""});
                    $("#alterarPagamento").maskMoney({symbol:"R$",decimal:".",thousands:""});
                });
            </script>
            <script>
                jQuery(function($){
                    $("#inicio").mask("99/99/9999");
                    $("#fim").mask("99/99/9999");
                });
            </script>
            <script>
                $(function(){
                    $.datepicker.setDefaults($.datepicker.regional["pt-BR"]);
                    $("#inicio").datepicker();
                    $("#fim").datepicker();
                });	
            </script>
        </head>
        <body>
            <div class="total2">
                <?php
                include_once 'titulo.php';
                ?>
                <div class="cabecalho">
                </div>
                <?php
                include_once 'menuHorizontal.php';
                ?>
                <div class="total">
                    <div class="conteudo">
                        <div style="width: 80%; margin-left: auto; margin-right: auto;">
                            <?php
                            $sql = "SELECT *FROM tbl_inst_serv WHERE ins_ser_id = " . $_GET['ID'] . "";
                            $resultado = executaSQL($sql);
                            $linha = mysqli_fetch_array($resultado);
                            ?>
                            <form action="script/acoes.php" method="post">
                                <input type="hidden" name="ACAO" value="EditarInstalador">
                                <table class='tblForm'>
                                    <caption>Editar Instalação</caption>
                                    <tr>
                                        <td><label>Instalação</label></td>
                                        <td><input type='text' name='INSTALACAO' readonly class='inputBloqueado' value='<?php echo $linha['ins_ser_id'] ?>'></td>
                                    </tr>
                                    <tr><td><label>Serviço</label></td>
                                        <td><input type='text' name='SERVICO' readonly class='inputBloqueado' value='<?php echo $linha['fk_cham_ser_id'] ?>'></td>

                                    </tr>
                                    <tr><td><label>Funcionario</label>
                                        <td>
                                            <select name="FUNCIONARIO" class="Input27px">

                                                <?php
                                                $sql = "SELECT * FROM tbl_funcionario";
                                                $resposta = executaSQL($sql);
                                                while ($linha = mysqli_fetch_array($resposta)) {
                                                    echo "<option value='" . $linha['fun_id'] . "'";
                                                    if ($linha["fun_id"] == $_GET["FUNCIONARIO"]) {
                                                        echo "SELECTED";
                                                    } else {
                                                        echo "";
                                                    };
                                                    echo ">";
                                                    echo $linha["fun_nome"];
                                                    echo "</option>";
                                                }
                                                echo "</select>";
                                                ?>
                                            </select>
                                        </td>

                                    <tr><td>
                                            <label class="">Carro</label>
                                        </td>
                                        <td><select name="CARRO" class="Input27px">
                                                <?php
                                                $sql = "SELECT * FROM tbl_carro";
                                                $resposta = executaSQL($sql);
                                                while ($linha = mysqli_fetch_array($resposta)) {
                                                    echo "<option value='" . $linha['car_id'] . "'";
                                                    if ($linha["car_id"] == $_GET["CARRO"]) {
                                                        echo "SELECTED";
                                                    } else {
                                                        echo "";
                                                    };
                                                    echo ">";
                                                    echo $linha["car_nome"];
                                                    echo "</option>";
                                                }
                                                echo "</select>";
                                                ?>
                                            </select>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>Inicio</td>
                                        <td><input type="text" name="INICIO" class="Input27px" id="inicio"
                                            <?php
                                            if ($_GET['INICIO']) {
                                                echo " value=\"";
                                                echo $_GET['INICIO'];
                                                echo "\" ";
                                            }
                                            ?>/></td>
                                    </tr>
                                    <tr>
                                        <td>Concluido</td>
                                        <td><input type="text" name="FIM" class="Input27px" id="fim"
                                            <?php
                                            if ($_GET['FIM']) {
                                                echo " value=\"";
                                                echo $_GET['FIM'];
                                                echo "\" ";
                                            }
                                            ?>/></td>
                                    </tr>
                                    <tr>
                                        <td colspan="2">

                                            <input type="submit" value="    Concluir" class="btnConcluido">
                                        </td>
                                    </tr>
                                </table>
                            </form>
                            <?php
                            ?>
                        </div>
                    </div>
                </div>
            </div>
        </body>
    </html>
    <?php
} else {
    header("location: session_expirada.php");
}
?>


<?php

function executaSQL($sql) {
    $mySQL = new MySQL;
    $resultado = $mySQL->execSP($sql);
    return $resultado;
}
?>
